<?php
require('../config.ini.php');
require('../fpdf/fpdf.php');
$pdf=new FPDF();
$pdf->SetMargins(10,15,10);
$pdf->AddPage();
$pdf->AddFont('angsa','','angsa.php');
$pdf->SetFont('angsa','',16);
$rwuserid = $_GET["rwuserid"];
$sql = "select * from userdata where userid = '$rwuserid'";
$result= mysql_query($sql);
$row = mysql_fetch_array($result);
$rusername = $row["username"];
$rlastname = $row["usersname"];
$conv = iconv("UTF-8","TIS-620","รายงานน้ำหนักของ $rusername $rlastname");
$pdf->Cell(0,0,$conv,0,0,'C');
$pdf->Ln(5);
$pdf->SetFont('angsa','',12);
//Loop แสดงรายการ

$sql = "SELECT * FROM `reportweight` WHERE userid = '$rwuserid'";
$query = mysql_query($sql);
$pdf->Cell(25,8,iconv("UTF-8","TIS-620","วันที่"),1,0,'C');
   $pdf->Cell(25,8,iconv("UTF-8","TIS-620","น้ำหนัก"),1,0,'C');
   $pdf->Cell(100,8,iconv("UTF-8","TIS-620", "รายละเอียดเพิ่มเติม"),1,0,'C');
   $pdf->Ln();
$cnt = 0;
while ($result = mysql_fetch_array($query))
{
   ++$cnt;
   $pdf->Cell(25,8,iconv("UTF-8","TIS-620", $result["reportdate"]),1,0,'L');
   $pdf->Cell(25,8,iconv("UTF-8","TIS-620", $result["weight"]),1,0,'L');
   $pdf->Cell(100,8,iconv("UTF-8","TIS-620", $result["description"]),1,0,'L');
   $pdf->Ln(); //ระหว่างบรรทัด
   //ถ้า 30 รายการให้ขึ้นหน้าใหม่
   if($cnt == 35)
   {
     $cnt = 0;
     $pdf->AddPage(); //เพิ่ม หน้า
   }
}

$pdf->Output();
?>
